package cn.com.pxto.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.com.pxto.commons.SearchParam;
import cn.com.pxto.commons.pagesupport.PageInfo;
import cn.com.pxto.dao.UserObjectRuleDAO;
import cn.com.pxto.global.varables.Global;
import cn.com.pxto.model.UserObjectRule;
import cn.com.pxto.service.RuleManager;
/**
 * 
 * Copyright (C) 2006 Bejing iActive Tec Co.,Ltd File: RuleManagerImpl.java
 * 
 * file description
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * @author Gauss Cheung 2006-7-20
 */


public class RuleManagerImpl implements RuleManager{
	private static Log log = LogFactory.getLog(RuleManagerImpl.class);
	private UserObjectRuleDAO  userObjectRuleDAO=null;
	/**
	 * spring����5ע��
	 * @param user_Object_RuleDAO
	 */
	public void setUserObjectRuleDAO(UserObjectRuleDAO userObjectRuleDAO){
	       this.userObjectRuleDAO = userObjectRuleDAO;	
	}
	/*
	 *  (non-Javadoc)
	 * @see cn.com.iactive.service.RuleManager#getUserFunctions(int)
	 */
	public List getUserFunctions(Integer userID) {
		log.info("getUserFunctions");
		return userObjectRuleDAO.listRulesBySrc(userID);
	}
	
	public List getUserFunctions(int userID) {
		//�������1��object = functions �г���Ȩ��
		//�������2��src = userid ������id
		/*
		SearchParam[] params = {
				new SearchParam("objectType",new Integer(Global.VISIT_OBJECT_FUNCTIONS),SearchParam.SEARCH_PARAM_TYPE_NUMBER),
				new SearchParam("src",new Integer(userID),SearchParam.SEARCH_PARAM_TYPE_NUMBER)
		};
		*/
		SearchParam[] params=null;
		//List list = userObjectRuleDAO.listRules(params);
		return userObjectRuleDAO.listRules(params);
	}
	

	
	/**
	 * �>�src��objectType����UserObjectRule�������Է�ҳ��
	 */
	public List getRulesBySrc(String src,Integer objectType,Integer srcType){
		 return userObjectRuleDAO.listRulesBySrc(src,objectType,srcType);
	 }
	 
	/**
	 * �>�src��objectType����UserObjectRule�����Է�ҳ��
	 */
	public List getRules(String src,Integer objectType,Integer srcType,PageInfo pageInfo){
		 return userObjectRuleDAO.listRules(src,objectType,srcType,pageInfo);
	}
	
	/**
	 * �>�src,object��objectType����UserObjectRule
	 */
	public List getRulesBySrcAndObject(Integer src,Integer objectType,Integer srcType,Integer object){
		return userObjectRuleDAO.listRulesBySrcAndObject(src,objectType,srcType,object);
	}
	
	 /**
	  *add or update the rule
	  */
	 public void saveRule(UserObjectRule rule){
		 userObjectRuleDAO.saveRule(rule);
	 }
	
	/**
	 * remove the rule by id
	 */
	 public void deleteRule(Integer id) {
		 userObjectRuleDAO.deleteRule(id);
	 }
	 
	 /**
	  * �>�src����UserObjectRule
	  */
	 public List getRulesBySrc(Integer src){
		 return userObjectRuleDAO.listRulesBySrc(src);
	 }
	 
	 /**
	  * ����UserObjectRule
	  */
		public List getRule(SearchParam[] params){
			return userObjectRuleDAO.listRule(params);
		}
}
